#!/usr/bin/env bash
set -e
set -u
set -o pipefail


source "${BASH_SOURCE%/*}/assertions.sh"


test_get_output_file() {
    local file_type=${1:?}
    local path=${2:?}
    local output_dir=${3:-?}
    source "${BASH_SOURCE%/*}/../src/utils/functions.sh"
    get_output_file "$file_type" "$path" "$output_dir"
}


test_get_output_file_main() {
    # NOTE: Related to get_working_ext returns the filename when no
    # ext
    assert_equal \
        "test_get_output_file" \
        "output/foo/glux" \
        "$(test_get_output_file "markdown" "glux" "output/foo")"
    assert_equal \
        "test_get_output_file" \
        "output/foo/glux.html" \
        "$(test_get_output_file "org" "glux.org" "output/foo")"
    assert_equal \
        "test_get_output_file" \
        "output/foo/glux.html" \
        "$(test_get_output_file "markdown" "glux.md" "output/foo")"
    assert_equal \
        "test_get_output_file" \
        "output/foo/glux.txt" \
        "$(test_get_output_file "org" "glux.txt" "output/foo")"
    assert_equal \
        "test_get_output_file" \
        "output/foo/glux.txt" \
        "$(test_get_output_file "markdown" "glux.txt" "output/foo")"
}


test_get_output_file_main
